package com.example.springbatch.processor;

import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.batch.item.ItemProcessor;

import java.util.Collection;

/**
 * Created by Liaopan on 2018/9/6.
 */
@Slf4j
public class LogItemProcesser implements ItemProcessor<Object, String> {

    @Override
    public String process(final Object obj) throws Exception {
        if(obj instanceof String){
            return (String) obj;
        }
        if(obj instanceof Collection) {
            return StringUtils.join((Iterable<String>) obj,",");
        }
        return obj.toString();
    }
}
